package com.zx.easy.converter;


import cn.hutool.core.date.DateUtil;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;

@Component
@Named(value = "StructHelper")
public class StructHelper {

    /**
     * 时间搓转换程日期格式
     * @param timeMillis
     * @return
     */
    @Named(value = StructConstant.TIME_MILLIS_TO_DATE_STR)
    public static String dateStrToTimeMillis(Long timeMillis) {

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(timeMillis);
    }


    @Named(value = StructConstant.DATE_STR_TO_TIME_MILLIS)
    public static Long timeMillisToDateStr(String dateStr) {
        return DateUtil.parseDateTime(dateStr).getTime();
    }

    @Named(value=StructConstant.DATE_STR_TO_LOCAL_DATE)
    public static LocalDateTime dateStrToLocalDateTime(String dateStr) {
        return DateUtil.parseLocalDateTime(dateStr);
    }




}
